package hospital.cmn.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import hospital.cmn.mapper.DictMapper;
import hospital.model.cmn.Dict;
import hospital.vo.cmn.DictEeVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author
 * @description:
 */
public class DictListener extends AnalysisEventListener<DictEeVo> {

//    AnalysisEventListener 不建议使用@Autowired
    private DictMapper dictMapper;
    public DictListener(DictMapper dictMapper) {
        this.dictMapper = dictMapper;
    }

    //一行一行的导入数据
    @Override
    public void invoke(DictEeVo vo, AnalysisContext analysisContext) {
        Dict dict=new Dict();
        BeanUtils.copyProperties(vo,dict);
        dictMapper.insert(dict);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
